package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import papers.Manuscript;

/**
 * A panel that display manuscript info.
 * @author Dickson Kwong
 * @version v1.2 Nov. 30, 2011
 */

@SuppressWarnings("serial")
public class PCInfoPanel extends JPanel {
	
	/**
	 * The PCInfoPanel Constructor. It creates 
	 * a panel to display manuscript info.
	 * @param the_manuscript The manuscript
	 * @param the_frame The frame
	 */
	public PCInfoPanel(final Manuscript the_manuscript, final JFrame the_frame) {
	    super(true);
	    setLayout(new BorderLayout());
	    setSize(200, 600);
	    setup(the_manuscript, the_frame);
	}
	
	/**
	 * It add all the necessary label to the panel.
	 * @param the_manuscript The manuscript
	 * @param the_frame The frame
	 */
	private void setup(final Manuscript the_manuscript, final JFrame the_frame){
	    JLabel author = new JLabel("  Author: " + 
	    		the_manuscript.getAuthor().getName() + "  ", SwingConstants.CENTER); 
	    JLabel title = new JLabel("Paper Title: " + 
	    		the_manuscript.getPaperName(), SwingConstants.CENTER);
	    
	    JLabel list_view = new JLabel("  Return to list view  ", SwingConstants.CENTER);
	    
	    list_view.addMouseListener(new MouseAdapter()   
        {  
	        public void mouseClicked(MouseEvent evt)  
	        {  
	        	the_frame.dispose();
	        }
        });
	    
	    author.setBorder(BorderFactory.createLineBorder(Color.black));
	    title.setBorder(BorderFactory.createLineBorder(Color.black));
	    list_view.setBorder(BorderFactory.createLineBorder(Color.black));
	    
	    //Set the font for the labels.
	    Font f = new Font("Dialog", Font.PLAIN, 24);
	    author.setFont(f);
	    title.setFont(f);
	    list_view.setFont(f);
	    
	    //Add all the labels to the panel
	    add(author, BorderLayout.WEST);
	    add(title, BorderLayout.CENTER);
	    add(list_view, BorderLayout.EAST);		
	}
}
